package com.gupao.session;

import javax.servlet.http.HttpServletRequest;

import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class IndexController {
	
	@RequestMapping("/index")
	@ResponseBody
	public String index(HttpServletRequest request,@Param(value = "name") String name,@Param(value = "password") String password) {
		request.getSession().setAttribute(name, password);
		return "success";
	}
	
	@GetMapping("/getPassword")
	@ResponseBody
	public String getPassword(HttpServletRequest request,@Param(value = "name") String name) {
		return String.valueOf(request.getSession().getAttribute(name));
	}
}
